import {
  reqSearchInfo
} from '../../api'
const state = {
  searchList: {}
}
const mutations = {
  SEARCHINFO(state, searchList) {
    state.searchList = searchList
  }
}
const actions = {
  //获取search数据
  async getSearchInfo({
    commit
  }, params = {}) {
    let result = await reqSearchInfo(params)
    if (result.code == 200) {
      commit('SEARCHINFO', result.data)
    }
  }
}
//相当于计算属性，简化数据
const getters = {
  goodsList(state) {
    return state.searchList.goodsList || []
  },
  trademarkList(state) {
    return state.searchList.trademarkList || []
  },
  attrsList(state) {
    return state.searchList.attrsList || []

  }
}
export default ({
  state,
  mutations,
  actions,
  getters
})